#coding=utf-8 
from django.db import models
from products.models import Product
# Create your models here.

#用户注册信息
class User(models.Model):
    username = models.CharField(max_length = 50, primary_key=True)
    password = models.CharField(max_length = 50)
    email = models.EmailField()
    mobile = models.IntegerField()
    
#用户实名信息
class UserIdentity(models.Model):
    user = models.OneToOneField(User, primary_key = True)
    name = models.CharField(max_length = 50)
    id_type = models.CharField(max_length = 20, choices = (('id', '身份证'), ('passport', '护照'),))
    id_number = models.CharField(max_length = 50) 
    identity_datetime = models.DateTimeField()
    
#用户资产信息
class UserAsset(models.Model):
    user = models.OneToOneField(User, primary_key = True)
    balance = models.FloatField()
    asset = models.FloatField()
    profit = models.FloatField()
    profit_rate = models.FloatField()
    
#用户银行卡信息
class UserBankCard(models.Model):
    user = models.ForeignKey(User)
    card_number = models.IntegerField()
    bank_name = models.CharField(max_length = 20)
    bank_city = models.CharField(max_length = 20)
    bank_branch = models.CharField(max_length = 20)
    
#用户产品投资信息
class UserInvest(models.Model):
    user = models.ForeignKey(User)
    product = models.ForeignKey(Product)
    capital = models.FloatField()
    profit = models.FloatField()
    invest_datetime = models.DateTimeField()
    